package com.xinruke.hostels.reservation.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.reservation.interfaces.dto.*;
import com.xinruke.hostels.reservation.service.RestaurantOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author chenry
 * @ClassName RestaurantController
 * @date：2019/6/19
 * @version: V1.0.0
 * @description：餐厅预订
 */
@RestController
@RequestMapping("/restaurant/")
@Api(tags = "餐厅预订管理")
public class RestaurantController extends BaseController {

    @Resource
    RestaurantOrderService restaurantOrderService;


    /**
     * 餐厅预订
     * 1.1.校验是否有预订
     *
     * @return 预订结果
     */
    @PostMapping("/submit")
    @ApiOperation("提交")
    public ResultVO<String> submit(@Valid @RequestBody RestaurantSubmitInfoDto params) {
        return restaurantOrderService.submit(params);

    }

    /**
     * 取消订单
     */
    @PostMapping("/cancel")
    @ApiOperation("取消订单")
    public ResultVO<String> cancel(@Valid @RequestBody RestaurantCancelDto params) {
        return restaurantOrderService.cancel(params);
    }


    /**
     * 删除订单
     * 暂未发现接口
     */
    @PostMapping("/del")
    @ApiIgnore
    @ApiOperation("删除订单")
    public ResultVO<String> delOrder(@Valid @RequestBody RestaurantDelDto params) {
        return restaurantOrderService.del(params);
    }

    /**
     * 订单列表
     *
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("订单列表")
    public ResultVO<RowsDataVO<RestaurantListQueryResultDto>> list(@Valid @RequestBody RestaurantListQueryDto params) {
        ResultVO<RowsDataVO<RestaurantListQueryResultDto>> resultVO = ResultVO.success();
        RowsDataVO<RestaurantListQueryResultDto> list = restaurantOrderService.list(params);
        resultVO.setData(list);
        return resultVO;
    }


    /**
     * 订单列表
     *
     * @return
     */
    @PostMapping("/detail")
    @ApiOperation("订单详情")
    public ResultVO<RestaurantDetailQueryResultDto> orderDetail(@Valid @RequestBody RestaurantDetailQueryDto params) {
        return restaurantOrderService.detail(params);
    }

}
